<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>管理员列表</title>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" media="all">
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/x-layui.js" charset="utf-8"></script>

    <script>
        layui.use(['laydate','element','laypage','layer'], function(){});
    </script>

</head>
<body>

<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>管理员管理</cite></a>
              <a><cite>管理员列表</cite></a>
            </span>

    <button class="layui-btn x-right" style="margin-left: 10px;"
            onclick="javascript:location.replace(location.href);">
        <i class="layui-icon">ဂ</i>&nbsp;&nbsp;刷新
    </button>
    <button class="layui-btn x-right "
            onclick="add('添加管理员 ','${pageContext.request.contextPath}/admin/addUi','600','500')">
        <i class="layui-icon">&#xe608;</i>&nbsp;&nbsp;添加
    </button>
</div>

<div class="x-body">
    <table class="layui-table">
        <thead>
        <tr>
            <th>序号</th>
            <th>管理员编号</th>
            <th>用户名</th>
            <th>密码</th>
            <th>盐</th>
            <th>角色</th>
            <th>头像</th>
            <th>注册时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <c:forEach items="${adminAndRoles}" var="adminAndRole" varStatus="status">
            <tr>
                <td>${status.index + 1}</td>
                <td>${adminAndRole.id}</td>
                <td>${adminAndRole.username}</td>
                <td>${adminAndRole.password}</td>
                <td>${adminAndRole.salt}</td>
                <td>${adminAndRole.rname}</td>
                <td>
                    <img src="${pageContext.request.contextPath}/images/${adminAndRole.header}" width="40px">
                </td>
                <td>
                    <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                    value="${adminAndRole.createTime}"/>
                </td>
                <td class="td-status">
                    <c:if test="${adminAndRole.state == 1}">
                        <span class="layui-btn layui-btn-danger"> 禁用 </span>
                    </c:if>
                    <c:if test="${adminAndRole.state == 0}">
                        <span class="layui-btn layui-btn-normal"> 启用 </span>
                    </c:if>
                </td>
                <td class="td-manage">
                    <a title="编辑" href="javascript:;"
                       onclick="edit('编辑管理员','${pageContext.request.contextPath}/admin/editUi', ${adminAndRole.admin.id},'','510')"
                       class="ml-5" style="text-decoration:none">
                        <i class="layui-icon">&#xe642;</i>
                    </a>
                </td>
            </tr>
        </c:forEach>

        </tbody>
    </table>

</div>


<script>

    /*添加*/
    function add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }

    //编辑
    function edit (title,url,id,w,h) {
        url = url+"?id="+id;
        x_admin_show(title,url,w,h);
    }

</script>

</body>
</html>